<template>
  <div>
    <!-- <div class="button-search-content">
          <file-button-group :button-array="buttonArray" />
          <search />
        </div> -->
    <bread-crumb />
    <file-table />
  </div>
</template>

<script>
import FileButtonGroup from '@/components/file-button-group/'
import Search from '@/components/search'
import BreadCrumb from '@/components/breadcrumb'
import FileTable from '@/components/file-table'
import { mapMutations, mapActions, mapGetters } from 'vuex'

export default {
  name: 'Files',
  components: { FileButtonGroup, Search, BreadCrumb, FileTable },
  props: [],
  data() {
    return {
      // buttonArray: [
      //   'upload',
      //   'createFolder',
      //   'download',
      //   'delete',
      //   'rename',
      //   'share',
      //   'copy',
      //   'transfer',
      // ],
    }
  },
  methods: {
    ...mapMutations({
      resetFileTypes: 'file/setFileTypes',
      resetFileParentId: 'file/setFileParentId',
      addBreadCrumbItem: 'breadcrumb/addItem',
      clearBreadCrumb: 'breadcrumb/clear',
      setSearchFlag: 'file/setSearchFlag',
    }),
    ...mapActions({
      reloadFileList: 'file/loadFileList',
    }),
    init() {
      let _this = this
      let firstItem = {
        id: this.defaultParentId,
        name: '其他文件',
      }
      this.clearBreadCrumb()
      this.addBreadCrumbItem(firstItem)
      _this.setSearchFlag(false)
      _this.resetFileParentId('-1')
      _this.resetFileTypes('2__,__1')
      _this.reloadFileList()
    },
  },
  computed: {
    ...mapGetters(['defaultParentId', 'defaultParentFilename', 'searchFlag']),
  },
  mounted() {
    this.init()
  },
  watch: {},
}
</script>

<style scoped>
.button-search-content {
  display: flex;
  width: 100%;
}
</style>
